import request from './http'
const baseUrl = '/actionapi/' // 基础url地址

// 用户登录接口
export const login = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/Login',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 客户查询接口
export const getCustList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCust',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 服务类型查询接口
export const getServiceType = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetServiceType',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 联系人查询接口
export const getPeoList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetPeo',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 合同名称查询接口
export const getPactList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetPact',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 获取客户地址接口
export const getCustAddress = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCustAddress',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 部门查询接口
export const getDepartmentList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetDepartment',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 任务发布接口
export const addMySer = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/Add',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 任务查询接口
export const getMySerList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetMySer',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 日志填写接口
export const addApiLog = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/AddApiLog',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 日志查询接口
export const getApiLog = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetApiLog',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 图片上传接口
export const uploadImage = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/UploadImage',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 到达现场
export const updateState = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/UpdateState',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 历史任务
export const getMyHistorySer = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetMyHistorySer',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 费用类别查询
export const getCostType = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCostType',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 查询费用
export const getCost = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 添加费用
export const addCost = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/AddCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 修改费用
export const UpdateCost = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/UpdateCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 历史任务套打
export const printSer = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/PrintServices',
      method: 'post',
      data: parameter
    }).then(res => {
      var myFrame = document.createElement('iframe')
      myFrame.src = '/Upload/' + res.result // 服务器路径
      myFrame.style.display = 'none'
      document.body.appendChild(myFrame)
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 历史任务打印
export const PrintSerTask = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/PrintServicesTask',
      method: 'post',
      data: parameter
    }).then(res => {
      var myFrame = document.createElement('iframe')
      myFrame.src = '/Upload/' + res.result // 服务器路径
      myFrame.style.display = 'none'
      document.body.appendChild(myFrame)
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 查询需要审核的费用接口
export const getCostDepartmentList = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCostDepartmentsApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询审核退回的费用
export const GetCostReviewTheReturn = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCostReviewTheReturn',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询已审核的费用
export const GetCostChecked = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetCostChecked',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 提交审核费用接口
export const CostSubmit = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/CostSubmit',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 领导审核费用接口
export const costDepartments = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/CostDepartmentsApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 公司审核接口
export const costCompany = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/CostCompanyApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 财务审核接口
export const costFinance = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/CostFinanceApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 领导人表单查询接口
export const getDepApproval = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetDepApprovalFormCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 公司表单查询接口
export const getComApproval = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetComApprovalFormCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 财务表单查询接口
export const getFinApproval = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetFinApprovalFormCost',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 查询费用详情
export const getApprovalForm = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetApprovalFormCostDetails',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询请假表单
export const getStaffAPILeave = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetStaffAPILeave',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询请假人员名单
export const GetTechnician = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetTechnician',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 新建修改请假提交表单
export const AddStaffAPILeave = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/AddStaffAPILeave',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询请假类型
export const GetLeaveType = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetLeaveType',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 删除请假表单
export const DeleteStaffAPILeave = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/DeleteStaffAPILeave',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 请假打印
export const PrintLeaveTask = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/PrintLeaveTask',
      method: 'post',
      data: parameter
    }).then(res => {
      var myFrame = document.createElement('iframe')
      myFrame.src = '/Upload/' + res.Data // 服务器路径
      myFrame.style.display = 'none'
      document.body.appendChild(myFrame)
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询请假类型
export const GetStaffAPILeaveChecked = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetStaffAPILeaveChecked',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 请假审核
export const LeaveApproval = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/LeaveApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 新建修改绩效考核提交表单
export const AddAssessForm = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/AddAssessForm',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询绩效考核表
export const GetAssessForm = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/GetAssessForm',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 删除绩效考核表
export const DeleteAssessForm = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/DeleteAssessForm',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      }
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 绩效考核表审核
export const AssessFormApproval = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/AssessFormApproval',
      method: 'post',
      data: parameter
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 绩效考核表导出
export const ExportAssessForm = (parameter) => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'RegisterApi/ExportAssessForm',
      method: 'post',
      data: parameter,
      headers: {
        'Content-Type': 'application/json'
      }
    }).then(res => {
      var myFrame = document.createElement('iframe')
      myFrame.src = '/Upload/' + res.Data // 服务器路径
      myFrame.style.display = 'none'
      document.body.appendChild(myFrame)
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询数据展示中的今日待办数据
export const GetDefaultSer = () => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'ServicesApi/GetDefaultSer',
      method: 'post',
      data: ''
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询数据展示中的周待办
export const GetWeekDefaultSer = () => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'ServicesApi/GetWeekDefaultSer',
      method: 'post',
      data: ''
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
// 查询数据展示中的本周人员数据
export const GetWeekDefaultSerSwitch = () => {
  return new Promise((resolve, reject) => {
    request({
      url: baseUrl + 'ServicesApi/GetWeekDefaultSerSwitch',
      method: 'post',
      data: ''
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}
